<?php
   /***************************************************************************************************
     PROGRAM DESCRIPTION :  PROGRAM TO VIEW waiting affiliates rotator applicatons
      VARIABLES          :   $MERCHANTID           =merchantid
                             $id                   =affilaiteid
                             $joinid               =joinid
                             $rid                  =rotatorid
                             $mode                 =get input type
                             $to				   =login_email
                             $status               =getting Transaction Statistics from transaction.php
                             $details              =getting Affiliate Staistics   from transaction.php
  //*************************************************************************************************/


  include "transactions.php";
  include "../mail.php";

  /*****************************variables**************************************/
  $MERCHANTID                                =$_SESSION['MERCHANTID'];   //merchantid
  $id                                        =trim($_POST['joinid']);    //joinid
  $id                                        =explode("~",$id);
  $joinid                                    =$id[0];
  $rid                                       =$id[1];
  $mode                                      =($_SERVER['REQUEST_METHOD'] == "POST" ? 1 : "");     //get input type
 /******************************************************************************/


 /*********************actions selecetd****************************************/
if($mode){
      if(trim($_POST['Approve'])){     //approve affiliate
              $sql                        ="update partners_rotatorsta set rotatorsta_status='approved' where rotatorsta_id=$id[1]  ";
              mysql_query($sql);
              GetTotalPro($joinid,$MERCHANTID) ;
  		}

      if(trim($_POST['Reject'])){          //reject affiliate
              $sql                        ="update partners_rotatorsta set rotatorsta_status='suspend' where rotatorsta_id=$id[1]  ";
              mysql_query($sql);
      }

      if(trim($_POST['change'])){         //change program
              header("Location:index.php");
              exit();
      }
}
  /****************************************************************************/

   //adding to drop down box
  $sql="select * from partners_rotatorsta,partners_rotator where rotatorsta_merid=$MERCHANTID  AND rotator_id=rotatorsta_roid";
  $result                        =mysql_query($sql);
  $result1                       =mysql_query($sql);


  //if records found
  if (mysql_num_rows($result1)>0) //checking for records
  {
              $rows                     =mysql_fetch_object($result1);
              $id                       =$rows->rotator_affilid;      //first time
              $rid                      =$rows->rotatorsta_id;


              if (empty($joinid))
                  { // for first time
                     $joinid        =$id;
                     $rid           =$rows->rotatorsta_id;
                     $pgmid         =$rows->joinpgm_programid;
                  }

              /********************getting affilaite details*******************/
              $status                =GetAffiliateStatus1($rid); // get affiliates details (join date)from transactions.php
              $status                =explode('~',$status);
              $details               = GetAffiliateDetails1($joinid);  // get affiliates details from transactions.php
              $details               =explode('~',$details);
              /***************************************************************/

             ?>
            <br/>
            <form name="GetAffiliate" method="post" action="index.php?Act=waitrotator">

            <!-- table 1-->
            <table border="0" cellpadding="0" cellspacing="0"  width="95%" align= "center"class="tablebdr1" >
                 <tr>
                   <td width="100%" class="tdhead" colspan="2" align="center"> <?=$lang_rtr_AffiliatesStaistics?></td>
                </tr>
                <tr>

                       <td width="70%" height="30" align="right" ><?=$lang_rtr_Affiliate?>
                                <select name="joinid" onchange="document.GetAffiliate.submit()">
                                    <?  while($row=mysql_fetch_object($result))
                                           {
                                           if($joinid=="$row->rotator_affilid")
                                                  $AffiliateName="selected = 'selected'";
                                           else
                                            $AffiliateName="";

                                           ?>
                                             <option <?=$AffiliateName?> value="<?=$row->rotator_affilid."~".$row->rotatorsta_id?>"> PgmID=<?=$row->rotatorsta_id?>&nbsp;<?=stripslashes($row->rotator_affilid)?> </option>
                                           <?

                                           }
                                           ?>
                                </select>
                   </td>
                 </tr>
                 <tr>
                       <td width="80%" align="center" colspan="3" >
                       <br/>

                       <!-- table 2 -->
                         <table border="0" cellpadding="0"  width="80%" class="tablebdr" >
                          <tr>
                            <td width="100%" colspan="2" class="tdhead"><?=$lang_rtr_PersonalDetails?></td>
                          </tr>
                           <tr>
                            <td width="50%" height="20" class="grid1"><?=$lang_rtr_Name?></td>
                            <td width="50%" height="20" class="grid1"><?=$details[0]?></td>
                          </tr>
                          <tr>
                            <td width="50%" height="20" class="grid1"><?=$lang_rtr_JoiningStatus?></td>
                            <td width="50%" height="20" class="grid1"><?=$status[0]?></td>
                          </tr>
                          <tr>
                            <td width="50%" height="20" class="grid1"><?=$lang_rtr_Category?></td>
                            <td width="50%" height="20" class="grid1"><?=$details[4]?></td>
                          </tr>
                          <tr>
                            <td width="50%" height="20" class="grid1"><?=$lang_rtr_Company?></td>
                            <td width="50%" height="20" class="grid1"><?=$details[1]?></td>
                          </tr>
                           <tr>
                            <td width="50%" height="20" class="grid1"><?=$lang_rtr_SiteUrl?></td>
                            <td width="50%" height="20" class="grid1"><?=$details[2]?></td>
                          </tr>
                          <tr>
                            <td width="50%" height="20" class="grid1"><?=$lang_rtr_SiteTraffic?></td>
                            <td width="50%" height="20" class="grid1"><?=$details[3]?></td>
                          </tr>
                          <tr>
                            <td width="100%" height="20" class="grid1" colspan="2" align="center">
                             <input type="submit" name="Reject" value="<?=$common_reject?>" style="width: 100" onclick="return confirmDelete()" />
                             <input type="submit" name="Approve" value="<?=$common_approve?>"  style="width: 100" />
                            </td>
                          </tr>
                        </table>
                       <!--close table 2-->

                       </td>
                 </tr>
                 <tr>
                       <td width="100%" height="20" colspan="3">
                       </td>
                 </tr>
				<tr>
                       <td width="100%" height="20"   align="center" class="tdhead" colspan="3">


                       </td>
                 </tr>
              </table>
              <!--close table 1-->
              </form>
                <?
      }
         else     //no records
                      {
                    ?>

                    <!-- table 3 Err msg-->
                     <table width="100%" align="center">
                     <tr>
                        <td align="center" class="red"><?=$norec?>
                        </td>
                     <tr>
                     </table>
                     <!--close table 3-->

                     <?
                     }
                     ?>


   <!-- delete confirmation-->
<script language="javascript" type="text/javascript">

   function confirmDelete()
   {
   var del=window.confirm("<?=$lang_rtr_Suspend?> ") ;
   if (del)
      return true;
   else
      return false;
   }

</script>